package com.test.demo4;

import com.test.demo2.UserService;
import com.test.demo2.UserServiceImpl;

public class Client {
    public static void main(String[] args) {
        //真实角色
        UserServiceImpl service = new UserServiceImpl();
        //代理角色，不存在
        ProxyInvocationHandler handler = new ProxyInvocationHandler();
        handler.setTarget(service);//设置要代理的对象
        //动态生成代理类
        UserService proxy = (UserService) handler.getProxy();
        proxy.query();
        proxy.update();
        proxy.add();
        proxy.delete();
    }
}
